<template>
	<view class="pl-20r pr-20r">
		<!-- 图片选择 -->
		<view class="pb-20r" style="border-bottom: 2rpx solid #E5E5E5 ;">
			<text class="text-light text-20r">最多选择9张图片</text>
			<uni-file-picker ref="uploadFiles" v-model="imageValue" :auto-upload='false' mode="grid" limit="9" @select="select" @progress="progress" @success="success"
				@fail="fail"></uni-file-picker>
		</view>

		<!-- 填写正文 -->
		<view class="">
			<fui-textarea v-model="dynamic.content" maxlength="200" isCounter textareaBorder placeholder="添加正文"></fui-textarea>
<!-- 			<uni-easyinput type="textarea" autoHeight v-model="dynamic.content" placeholder="添加正文"></uni-easyinput> -->
		</view>

		<!-- 话题 艾特用户 -->
		<view class="flex text-center mt-20r mb-20r">
			<view class="text-main mr-20r text-20r rounded-10r w-90r h-40r leading-40r"
				style="background-color: #E5E5E5;">#话题</view>
			<view class="text-main text-20r rounded-10r w-90r h-40r leading-40r" style="background-color: #E5E5E5;">#用户
			</view>
		</view>

		<!-- 分割线 -->
		<!-- <view class="h-2r third-bg-color" style=""></view> -->

		<!-- 添加当前位置 -->

		<!-- 底部导航栏 -->
		<view class="fixed bottom-20r pt-10r box-border" style="width: 100%;border-top: 2rpx solid #E5E5E5;">
			<view class="flex h-100r items-center justify-around">
				<view class="flex flex-col w-80r items-center text-center">
					<text
						class="third-bg-color block rounded-35r font-bold text-deep leading-70r text-40r w-70r h-70r iconfont icon-caogaoxiang"></text>
					<text class="text-main text-20r">存草稿</text>
				</view>
				<view @click="publish" class="mr-40r rounded-45r w-500r h-90r text-40r font-bold text-center leading-90r"
					style="color:#fff; background-color: red;">发布动态</view>
			</view>
		</view>




	</view>
</template>

<script>
	export default {
		data() {
			return {
				imageValue:[],
				dynamic:{
					dynamic_banner_imgs:[],
					content:'',
					dynamic_status:1
				}
			};
		},
		onLoad() {
			
		},
		methods:{
			async publish(){
				if (this.stringUtils.isBlank(this.dynamic.content)) {
					vk.toast("请输入正文");
					return;
				}
				try{
					vk.showLoading("发布中...");
					await this.$refs.uploadFiles.upload();		
				}catch(e){
					//TODO handle the exception
				}
				
			},
			progress(e){
				// console.log(e);
			},
			select(){
				
			},
			success(e){
				console.log(e);
				this.dynamic.dynamic_banner_imgs = e.tempFilePaths;
				vk.callFunction({
					url: 'client/dynamic/kh/publishDynamic',
					data: this.dynamic
				}).then((r) => {
					uni.navigateBack();
				}).finally(r=>{
					vk.hideLoading();
				});
				
				
			},
			fail(){
				vk.toast("发布失败，请重试", "fail");
			}
		}
	}
</script>

<style lang="scss">

</style>
